package com.hefei.controller;

import com.hefei.entity.CustInfo;
import com.hefei.service.CustInfoService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Controller
public class CustInfoController {

    @Autowired
    private CustInfoService custInfoService;

    @GetMapping("/index.html")
    public String custInfoList(Map<String,List> res){
        List<CustInfo> custInfoList = custInfoService.findAll();
        res.put("custInfoList",custInfoList);
        return "index";
    }

    @PostMapping("/add")
    public String addCustInfo(CustInfo custInfo){
        custInfoService.add(custInfo);
        return "redirect:/index.html";
    }

    //  /delete/001
    @RequestMapping("/delete/{custNo}")
    public String deleteCustInfo(@PathVariable String custNo){
        custInfoService.delete(custNo);
        return "redirect:/index.html";
    }





}
